package com.zemb.flxwear.Utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SharePreferencesUtils {
    //单例模式
    private static SharePreferencesUtils instance;
    private SharedPreferences sharedPreferences;
    private SharePreferencesUtils(){
        
    }
    public static SharePreferencesUtils getInstance(){
        if(instance == null){
            instance = new SharePreferencesUtils();
        }
        return instance;
    }
    public void init(Context context){
        sharedPreferences = context.getSharedPreferences("FLX",Context.MODE_PRIVATE);
    }

    //修改数据
    public boolean putString(String key,String value){
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key,value);
        return editor.commit();
    }

    //获取数据
    public String getString(String key){
        return sharedPreferences.getString(key,"");
    }
}
